package cn.xuexiyuan.flinkstudy.test;

import cn.xuexiyuan.flinkstudy.entity.Order;

import java.util.Random;
import java.util.UUID;

/**
 * @Description:
 * @Author 左龙龙
 * @Date 21-3-25
 * @Version 1.0
 **/
public class DataFactory {

    public static Order createRandomOrder(int maxUserId, int lateSeconds) {
        String[] channels = new String[]{"JDDJ", "MTWM", "ELEM", "YZ"};
        Random random = new Random();
        Order order = new Order();

        order.setChannel_keyword(channels[random.nextInt(channels.length)]);
        order.setSheetno(UUID.randomUUID().toString());
        order.setUser_id(random.nextInt(maxUserId));

        // 随机时间
        long time = System.currentTimeMillis() - random.nextInt(lateSeconds) * 1000 ;
        order.setOrder_time(time);
        order.setPayment_money(random.nextInt(500));

        return order;
    }
}
